package it.unibo.mumu;

import android.content.Context;
import android.graphics.Color;
import android.net.Uri;
import android.util.AttributeSet;
import android.view.Gravity;
import android.widget.ImageButton;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.TextView;

public class UniverseAvatar extends LinearLayout {

	private int idUniverse;
	private String labelText;
	private String avatarPath;

	private TextView labelView;
	private ImageButton universeImageButton;

	public UniverseAvatar(Context context) {
		this(context, -1, "universo Vuoto", "");
	}

	public UniverseAvatar(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}
	
	public UniverseAvatar(Context context, int id, String label, String avatarPath) {
		super(context);

		this.idUniverse = id;
		this.labelText = label;
		this.avatarPath = avatarPath;

		this.setOrientation(VERTICAL);
		LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(200, 200);
		llp.gravity = Gravity.CENTER;
		llp.setMargins(0, 0, 0, 0);
		
		this.universeImageButton = new ImageButton(getContext());
		this.universeImageButton.getBackground().setAlpha(0);
		this.universeImageButton.setScaleType(ScaleType.FIT_CENTER);
		this.universeImageButton.setImageURI(Uri.parse(this.avatarPath)); // todo mettere l'uri passato
		
		LinearLayout.LayoutParams llp2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
		llp2.gravity = Gravity.CENTER;
		this.labelView = new TextView(getContext());
		this.labelView.setText(label);
		this.labelView.setTextColor(Color.WHITE);
		
		this.addView(universeImageButton, llp);
		this.addView(labelView, llp2);
		
	}

	public int getIdUniverse() {
		return idUniverse;
	}

	public void setIdUniverse(int idUniverse) {
		this.idUniverse = idUniverse;
	}

	public String getLabelText() {
		return labelText;
	}

	public void setLabelText(String label) {
		this.labelText = label;
	}

	public ImageButton getUniverseImageButton() {
		return universeImageButton;
	}

}
